#!/usr/bin/env bash
pid=0

term_handler() {
  if [ $pid -ne 0 ]; then
    kill -SIGTERM "$pid" 2> /dev/null
    wait "$pid"
  fi
}

trap 'kill ${!}; term_handler' SIGINT SIGTERM

/usr/bin/Xvfb :99 -screen 0 1920x1080x24 -nolisten tcp 2> /dev/null &
DISPLAY=:99 "$@" &
pid="$!"

while kill -0 "$pid" 2> /dev/null; do
  wait "$pid"
done

